import React, {Component} from 'react'
import {FormattedMessage} from 'react-intl';
import { getCompany } from '../../../actions/company/index';
import {bindActionCreators} from 'redux'
import {connect} from 'react-redux';
class CompanyProfile extends Component {

    componentDidMount() {
        if(this.props.company.fetchCompany){
            this.props.getCompany();
        }
    }

    render() {
        const {company} = this.props;

        return(
            <div className="wrabox">
                <div className="bor_bt bor-jewelry"></div>
                <h1>
                    <span className="toy-icon"></span>
                    <FormattedMessage id='company_title' description='title' defaultMessage='Company Profile'/>
                    <span className="toy-icon"></span>
                </h1>
                <div className="bor_bt bor-default"></div>
                <div style={company.showEmpty ? {display:'none'} : {display: 'block'}}>
                    <div dangerouslySetInnerHTML={{__html:company.companyData}} />
                </div>
                <div style={company.showEmpty ? {display:'block'} : {display: 'none'}}>
                    <img src="../../static/img/Empty.png" alt="广告图片占位符" title="图片占位符" style={{display:'block',width:'375px',height:'316px',margin:'0 auto'}} />
                    <p className="noinfor-p">The company did not fill in the company information</p>
                </div>
            </div>
        )
    }
}

const mapStateToProps = ({company,home}) => ({
    company,
    home
});

const mapDispatchToProps = (dispatch) => {
    return {
        getCompany: bindActionCreators(getCompany, dispatch)
    }
};
export default connect(mapStateToProps, mapDispatchToProps)(CompanyProfile)